home *** CD-ROM | disk | FTP | other *** search
- Path: monkeys.com!not-for-mail
- From: rfg@monkeys.com (Ronald F. Guilmette)
- Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
- Subject: Re: float != float and floats as return types
- Date: 15 Feb 1996 01:15:26 -0800
- Organization: Infinite Monkeys & Co.
- Message-ID: <4futje$6a4@segfault.monkeys.com>
- References: <4ej9lb$mpc@fu-berlin.de> <DM04ur.I6u@cwi.nl>
- NNTP-Posting-Host: segfault.monkeys.com
-
- In article <DM04ur.I6u@cwi.nl>, Dik T. Winter <dik@cwi.nl> wrote:
- >In article <4ej9lb$mpc@fu-berlin.de> axl@zedat.fu-berlin.de writes:
- > > Hello,
- > > I am getting confused, about how C/C++ manage float binary operations,
- > > in particular multiplication. The next C++ example gives me surprising
- > > results:
- >...
- > > float quad( float );
- >...
- > > a = i/13.123123;
- > > b = a*a;
- > > c = quad(a);
- > > cout << (b - c) << '\t';
- > > cout << (b - a*a) << '\t';
- > > cout << (c - quad(a)) << '\n';
- >
- >Declaring a function as returning float does not imply that the actual
- >value returned is indeed a float!
-
- Yes, it does.
-
- Please check the ISO C standard and all relevant Committee responses to
- official Defect Reports before making incorrect claims.
-
- >In K&R times expressions involving
- >floats were calculated using doubles. Some compilers extended that
- >to functions declared as returning float: a double result was returned;
- >others did indeed truncate the return value to float. Thorough
- >reading of K&R does not lead to a clear solution here. In ANSI C both
- >are allowed.
-
- That is simply untrue.
- --
-
- -- Ron Guilmette, Roseville, CA -------- Infinite Monkeys & Co. ------------
- ---- E-mail: rfg@monkeys.com ----------- Purveyors of Compiler Test Suites -
- ------ Copyright (c) 1996 by Ronald F. Guilmette; All rights reserved. -----
-